package com.example.zheng.qq.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.zheng.qq.R;
import com.example.zheng.qq.entity.Information;

import java.util.List;

public class InfoAdapter extends ArrayAdapter<Information>{
    private int id;
    public InfoAdapter(Context context, int resource, List<Information>objects) {
        super(context, resource,objects);
        id=resource;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Information information=getItem(position);
        View view= LayoutInflater.from(getContext()).inflate(id,parent,false);
        ImageView picture=(ImageView)view.findViewById(R.id.pictureId);
        TextView description=(TextView)view.findViewById(R.id.description);
        picture.setImageResource(information.getPictureId());
        description.setText(information.getDescription());
        return view;
    }
}
